﻿
@{
    ViewBag.Title = "个人任务--指效";
}
<link href="/Static/styles/bootstrap.min.css" rel="stylesheet" />
<link href="~/Static/js/zui/css/zui.min.css" rel="stylesheet" />
<link type="text/css" rel="stylesheet" href="/Static/js/layui/css/layui.css" />
<script src="/Static/js/jquery/jquery-1.11.1.min.js"></script>
<script src="~/Static/js/zui/zui.min.js"></script>
<script src="/Static/js/layui/layui.js"></script>
<style>
    .label.task-status-doing {
        color: #D2322D
    }

    .label.task-status-done {
        color: #229F24
    }

    .label.task-status-waiting {
        color: #E48600
    }

    .label.task-status-cancel {
        color: #333
    }

    .taskMenu {
        width: 200px
    }

        .taskMenu + .page-content {
            margin-left: 220px;
        }

    #dropMenu {
        min-width: 200px;
    }

    #defaultMenu, #finishedMenu, #suspendMenu {
        min-width: 168px;
    }

    #groupBar .btn-group {
        margin-right: 15px;
    }

    #currentItem {
        margin-right: 1px;
    }

    .children {
        background: #f0f0f0;
    }

    .modal-team .table-form {
        margin: auto;
        width: 90%;
    }

    .modal-team .modal-content {
        padding: 5px;
    }

        .modal-team .modal-content .table-form td + td, .table-form th + th {
            padding-left: 5px;
        }

    .panel .panel-heading a:hover {
        text-decoration: none;
    }

    #menu .pull-right {
        margin-right: 5px;
    }

    .page-content > .panel > .panel-heading > .panel-actions {
        margin-left: -5px;
    }

    .tr-child, .tr-child > td {
        padding: 0;
    }

        .tr-child > td > table {
            padding: 5px;
            background-color: #fff;
            border: 2px solid #DDDDDD;
        }

    td.wait {
        color: #808080;
    }

    td.doing {
        color: #d2322d;
    }

    td.done {
        color: #229f24;
    }

    td.closed {
        color: #E48600;
    }

    td.cancel {
        color: #888888;
    }

    .w-290px {
        width: 310px;
        font-size: 12.8;
    }
    .w-120px {
        width: 140px;
    }
    .circular {
        width: 20px;
        height: 20px;
        border-radius: 50%;
        -moz-border-radius: 50%;
        -webkit-border-radius: 50%;
        float: left;
        margin-right: 5px;
    }

    .red {
        background-color: red;
    }

    .green {
        background-color: green;
    }

    .top-navbar-index {
        position: inherit;
        background-color: white;
        width: 100%;
        margin-bottom: 0;
    }

    .active {
        float: left;
    }

    .row {
        margin: 0;
        padding: 20px;
    }
    .layui-table {
        padding: 0;
        margin: 0;
    }
        .layui-table td {
            font-family: 微软雅黑;
            font-size: 14px !important;
            color: #666;
        }
</style>
@Html.Raw(ViewBag.SysAdminMainNavbar)
<input type="hidden" name="currentMid" id="currentMid" value="@ViewBag.CurrentMid" />
<input type="hidden" id="secondMenuId" name="secondMenuId" value="@ViewBag.SecondMenuId" />
<nav id='menu' style="width:98%">
    <ul class='nav'>
        <li class='active' onclick="jumpTaskByPoint(this,'projectTask')">
            <a href='javascript:;'>项目任务</a>
        </li>
        <li class='active' onclick="jumpTaskByPoint(this,'temporaryTask')">
            <a href='javascript:;'>临时任务</a>
        </li>
    </ul>
</nav>

<div class='with-menu' style="width:98%">
    <div class='row'>
        <div class='panel'>
            <div style="width:95%">
                <div class="form-inline">
                    <div class="form-group">
                        <ul class="nav nav-tabs">
                            <li class="nav-heading"></li>
                            <li class='active' onclick="getListByPoint(this,1)">
                                <a href='javascript:;' class="form-control">指派给我</a>
                            </li>
                            <li onclick="getListByPoint(this,2)">
                                <a href='javascript:;' class="form-control">由我创建</a>
                            </li>
                            <li onclick="getListByPoint(this,3)">
                                <a href='javascript:;' class="form-control">由我完成</a>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
            <form id='ajaxForm' method='post' action="" style="width:95%">
                <table class='layui-table' lay-size="sm">
                    <thead>
                        <tr class='text-center'>
                            <th class='w-60px' style="width:3%">
                                编号
                            </th>
                            <th class='w-40px' style="width:3%">
                                P
                            </th>
                            <th style="width:5%">
                                <a href='javascript:;'>名称</a>
                            </th>
                            <th class='w-100px' style="width:5%">
                                截止日期
                            </th>
                            <th class='w-80px' style="width:5%">
                                指派给
                            </th>
                            <th class='w-90px' style="width:5%">
                                任务状态
                            </th>
                            <th class='w-90px' style="width:5%">
                                创建日期
                            </th>
                            <th class='w-80px' style="width:5%">
                                消耗(h)
                            </th>
                            <th class='w-120px' style="width:5%">
                                预计剩余(h)
                            </th>
                            <th class='w-100px' style="width:5%">
                                进度
                            </th>
                            <th class='w-290px' style="width:20%">操作</th>
                        </tr>
                    </thead>
                    <tbody id="tbList"></tbody>
                </table>
                <div class='table-footer'>
                    <div class='pull-left text-danger'></div>
                    <div style='float:right; clear:none;' class='pager form-inline'>
                        <div id="myPager"></div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(function () {
        getList(1);
    });
    var pageIndex = 1, pageSize = 10, count = 0;
    function getList(selectType) {
        $.post("/Temporary_Task/GetTemporary_TaskList", { pageIndex: pageIndex, pageSize: pageSize, name: "", selectType: selectType, secondMenuId: $("#secondMenuId").val() }, function (data) {
            if (data.Code == 200) {
                $("#tbList").html(data.Data);
                count = data.TotalCount;
                initPage(selectType);
            } else {
                win.alert("获取数据失败");
            }
        });
    }

    function initPage(selectType) {
        layui.use(['laypage', 'layer'], function () {
            var laypage = layui.laypage
                , layer = layui.layer;
            //完整功能
            laypage.render({
                elem: 'myPager'
                , limit: pageSize
                , curr: pageIndex
                , count: count
                , theme: '#1E9FFF'
                , layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
                , jump: function (obj, first) {
                    if (!first) {
                        pageIndex = obj.curr;
                        pageSize = obj.limit;
                        getList(selectType);
                    }
                }
            });
        });
    }
    //创建任务
    function addTask() {
        window.location.href = "/Temporary_Task/Add?id=0&mid=" + $("#currentMid").val() + "&secondMenuId=" + $("#secondMenuId").val();
    }

    function look(obj) {
        var taskInfo = $(obj).attr("val");
        var tArray = taskInfo.split(',');
        window.location.href = "/Temporary_Task/Readonly?id=" + tArray[0] + "&mid=" + $("#currentMid").val() + "&secondMenuId=" + $("#secondMenuId").val();
    }
    //编辑
    function editTask(obj) {
        var taskInfo = $(obj).attr("val");
        var tArray = taskInfo.split(',');
        window.location.href = "/Temporary_Task/Edit?id=" + tArray[0] + "&mid=" + $("#currentMid").val() + "&secondMenuId=" + $("#secondMenuId").val();
    }
    //工时
    function workTimeTask(obj) {
        var taskInfo = $(obj).attr("val");
        var tArray = taskInfo.split(',');
        win.open("/Temporary_Task/WorkTime?fk_TaskId=" + tArray[0] + "&consumTime=" + tArray[1] + "&theTime=" + tArray[2] + "&secondMenuId=" + $("#secondMenuId").val(), 770, 370, tArray[3] + ".工时");
    }

    //开始
    function runTask(obj) {
        var taskInfo = $(obj).attr("val");
        var tArray = taskInfo.split(',');
        win.open("/Temporary_Task/Run?taskId=" + tArray[0] + "&consumTime=" + tArray[1] + "&theTime=" + tArray[2] + "&secondMenuId=" + $("#secondMenuId").val(), 770, 420, tArray[3] + ".开始");
    }
    //指派
    function appointTask(obj) {
        var taskInfo = $(obj).attr("val");
        var tArray = taskInfo.split(',');
        win.open("/Temporary_Task/AppointTask?taskId=" + tArray[0] + "&consumTime=" + tArray[1] + "&theTime=" + tArray[2] + "&secondMenuId=" + $("#secondMenuId").val(), 770, 370, tArray[3] + ".指派");
    }
    //完成
    function finishTask(obj) {
        var taskInfo = $(obj).attr("val");
        var tArray = taskInfo.split(',');
        win.open("/Temporary_Task/Finish?taskId=" + tArray[0] + "&consumTime=" + tArray[1] + "&theTime=" + tArray[2] + "&secondMenuId=" + $("#secondMenuId").val(), 770, 450, tArray[3] + ".完成");
    }
    //子任务
    function addChildTask(obj) {
        var taskInfo = $(obj).attr("val");
        var tArray = taskInfo.split(',');
        win.open("/Temporary_Task/Children?taskId=" + tArray[0] + "&consumTime=" + tArray[1] + "&theTime=" + tArray[2] + "&secondMenuId=" + $("#secondMenuId").val(), 770, 450, tArray[3] + ".子任务");
    }

    //关闭
    function closeTask(obj) {
        var taskInfo = $(obj).attr("val");
        var tArray = taskInfo.split(',');
        win.open("/Temporary_Task/Close?taskId=" + tArray[0] + "&consumTime=" + tArray[1] + "&theTime=" + tArray[2] + "&secondMenuId=" + $("#secondMenuId").val(), 770, 270, tArray[3] + ".关闭");
    }

    //跳转类型
    function jumpTaskByPoint(obj, type) {

        $(".nav-heading").html($(obj).children("a").html());
        $(obj).addClass("active").siblings().removeClass("active");
        pageIndex = 1;
        var currentAction = "";
        switch (type) {
            case "projectTask": { //查询项目任务
                window.location.href = "/PersonalSpace/MyProject_Task?mid=" + $("#currentMid").val() + "&secondMenuId=" + $("#secondMenuId").val();
                break;
            }
            case "temporaryTask": { //临时任务
                window.location.href = "/PersonalSpace/MyTemporary_Task?mid=" + $("#currentMid").val() + "&secondMenuId=" + $("#secondMenuId").val();
                break;
            }
            default:
        }
    }

    //快速切换
    function getListByPoint(obj, pointValue1) {
        $(obj).addClass("active").siblings().removeClass("active");
        pageIndex = 1;
        getList(pointValue1);
    }
</script>
